// src/mock/index.js
import Mock from "mockjs"; //导入mockjs
/**
 * 数据
 */
//个人信息
const Person = [
  {
    id: "555",
    name: "zt0",
    password: "666",
    sex: "女",
    age: 18,
    grade: "2022级",
    dept: "音乐学院",
  },
  {
    id: "666",
    name: "zt",
    password: "666",
    sex: "女",
    age: 18,
    grade: "2021级",
    dept: "计算机科学与技术学院",
  },
  {
    id: "777",
    name: "zt2",
    password: "666",
    sex: "女",
    age: 18,
    grade: "2022级",
    dept: "艺术学院",
  },
  {
    id: "888",
    name: "zt3",
    password: "666",
    sex: "女",
    age: 12,
    grade: "2024级",
    dept: "机械与自动化学院",
  },
  {
    id: "888",
    name: "admin",
    password: "666",
    sex: "女",
    age: 12,
    grade: "2024级",
    dept: "机械与自动化学院",
  },
];
//竞赛
const MatchStudy=[
  {
    id: "666",
    projectid:'1',
    projectname: "蓝桥杯",
    level: "国家级",
    degree:'一等奖',
    descript: "这是。。",
    date:'2022-3-9'
  },
  {
    id: "555",
    projectid:'2',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "666",
    projectid:'3',

    projectname: "计算机比赛",
    level: "校级",
    degree:'二等奖',
    descript: "这是一个计算机比赛呀",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'4',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'5',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'6',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'7',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
]
const getmatchStudy=[]
const MatchArt=[
  {
    id: "666",
    projectid:'1',
    projectname: "音乐比赛",
    level: "国家级",
    degree:'一等奖',
    descript: "这是。。",
    date:'2022-3-9'
  },
  {
    id: "555",
    projectid:'2',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "666",
    projectid:'3',

    projectname: "跳舞比赛",
    level: "校级",
    degree:'二等奖',
    descript: "这是一个计算机比赛呀",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'4',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'5',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'6',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'7',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
]
const getmatchArt=[]
//证书
const CertificateStudy=[
  {
    id: "666",
    projectid:'1',
    projectname: "普通话",
    level: "国家级",
    degree:'一等奖',
    descript: "这是普通话呀哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈11111111111111111111111111111111。。",
    date:'2022-3-9'
  },
  {
    id: "555",
    projectid:'2',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "666",
    projectid:'3',

    projectname: "英语四级证书",
    level: "校级",
    degree:'二等奖',
    descript: "这是一个英语证书呀",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'4',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'5',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'6',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'7',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
]
const getcertificateStudy=[]
const CertificateArt=[
  {
    id: "666",
    projectid:'1',
    projectname: "音乐证书",
    level: "国家级",
    degree:'一等奖',
    descript: "这是。。",
    date:'2022-3-9'
  },
  {
    id: "555",
    projectid:'2',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "666",
    projectid:'3',

    projectname: "跳舞证书",
    level: "校级",
    degree:'二等奖',
    descript: "这是一个计算机比赛呀",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'4',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'5',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'6',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'7',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
]
const getcertificateArt=[]
const CertificateVolunteer=[
  {
    id: "666",
    projectid:'1',
    projectname: "志愿者证书",
    level: "国家级",
    degree:'一等奖',
    descript: "这是。。",
    date:'2022-3-9'
  },
  {
    id: "555",
    projectid:'2',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "666",
    projectid:'3',

    projectname: "武汉马拉松志愿者",
    level: "校级",
    degree:'二等奖',
    descript: "这是一个计算机比赛呀",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'4',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'5',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'6',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'7',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
]
const getcertificateVolunteer=[]
//奖学金

//项目
const Project=[
  {
    id: "666",
    projectid:'1',
    projectname: "前后端分离项目",
    level: "国家级",
    degree:'一等奖',
    descript: "这是普通话呀哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈11111111111111111111111111111111。。",
    date:'2022-3-9'
  },
  {
    id: "555",
    projectid:'2',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "666",
    projectid:'3',

    projectname: "css项目",
    level: "校级",
    degree:'二等奖',
    descript: "这是一个英语证书呀",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'4',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "666",
    projectid:'5',

    projectname: "html项目",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'6',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'7',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
]
const getProject=[]
//实习
const Practice=[
  {
    id: "666",
    projectid:'1',
    projectname: "哈啰实习",
    level: "国家级",
    degree:'一等奖',
    descript: "这是普通话呀哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈11111111111111111111111111111111。。",
    date:'2022-3-9'
  },
  {
    id: "555",
    projectid:'2',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'3',

    projectname: "css项目",
    level: "校级",
    degree:'二等奖',
    descript: "这是一个英语证书呀",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'4',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'5',

    projectname: "html项目",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'6',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'7',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
]
const getPractice=[]
//论文
const Paper=[
  {
    id: "666",
    projectid:'1',
    projectname: "自动化检测论文",
    level: "国家级",
    degree:'一等奖',
    descript: "这是普通话呀哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈11111111111111111111111111111111。。",
    date:'2022-3-9'
  },
  {
    id: "555",
    projectid:'2',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'3',

    projectname: "css项目",
    level: "校级",
    degree:'二等奖',
    descript: "这是一个英语证书呀",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'4',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'5',

    projectname: "html项目",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'6',
    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
  {
    id: "555",
    projectid:'7',

    projectname: "18",
    level: "2022级",
    degree:'',
    descript: "音乐学院",
    date:'2022-3-9'

  },
]
const getPaper=[]

/**
 * 请求方法
 */
const testData = Mock.mock(
  "http://localhost:5173/test",
  "post",
  function (options) {
    // 这里的option是请求的相关参数
    console.log(JSON.parse(options.body).start);

    return Mock.mock({
      status: 200,
      dataList: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
    });
  }
);
//登录
const loginData = Mock.mock(
  "http://localhost:5174/",
  "post",
  function (options) {
    // 这里的option是请求的相关参数
    const name = JSON.parse(options.body).name;
    const password = JSON.parse(options.body).password;

    console.log(
      "mock获取的参数" +
        JSON.parse(options.body).name +
        JSON.parse(options.body).password
    );
    if (name == "zt" && password == "666") {
      console.log("登录请求成功");
      return Mock.mock({
        status: 200,
        dataList: [
          {
            id: "666",
          },
        ],
      });
    }
    return Mock.mock({
      status: 404,
      dataList: [
        {
          id: "error",
        },
      ],
    });
  }
);

//个人信息
const personData = Mock.mock(
  "http://localhost:5174/home/person",
  "get",
  function (options) {
    const id = JSON.parse(options.body).id;
    console.log(
      "mock获取的参数" +
        JSON.parse(options.body).id 
    );
    for (let i = 0; i < Person.length; i++) {
      if (Person[i].id == id) {
        return Mock.mock({
          status: 200,
          dataList: [
            {
              password: Person[i].password,
              sex: Person[i].sex,
              age: Person[i].age,
              grade: Person[i].grade,
              dept: Person[i].dept,
            },
          ],
        });
        
     }
      

	  
    }
    return Mock.mock({
			status: 404,
      message:'未查找到数据库中存在该id',
			dataList: [
			  {
				
			  },
			],
		  });
  }
);
const personSubmitData = Mock.mock(
  "http://localhost:5174/home/person/submit",
  "post",
  function (options) {
    const id = JSON.parse(options.body).id;
    console.log(
      "mock获取的参数" +
        JSON.parse(options.body).id 
    );
    for (let i = 0; i < Person.length; i++) {
      if (Person[i].id == id) {
        Person[i].dept=JSON.parse(options.body).dept ;
        Person[i].sex=JSON.parse(options.body).sex ;
        Person[i].age=JSON.parse(options.body).age ;
        Person[i].grade=JSON.parse(options.body).grade ;
        Person[i].name=JSON.parse(options.body).name ;

        return Mock.mock({
          status: 200,
          dataList: [
            {
              message:'提交数据成功'
            },
          ],
        });
        
     }
      

	  
    }
    return Mock.mock({
			status: 404,
			dataList: [
			  {
				message:'提交数据失败'
			  },
			],
		  });
  }
);

//竞赛
const matchStudyData = Mock.mock(
  "http://localhost:5174/home/match/study",
  "post",
  function (options) {
    const id = JSON.parse(options.body).id;
    console.log(
      "mock获取的参数" +
        id
    );
    let i=0,j=0
    for (i = 0,j=0; i < MatchStudy.length; i++) {
      if (MatchStudy[i].id == id) {
        console.log("找到了一个呢"+MatchStudy[i].projectname)

        getmatchStudy[j]=MatchStudy[i];
        j++;
     }
  
    }

    if(i<MatchStudy.length){
      return Mock.mock({
        status: 404,
        message:'你没有获得该竞赛奖呢',
        dataList: [
          {
          
          },
        ],
        });
    }else{
      console.log('获取竞赛成功')
      return Mock.mock({
        status: 200,
        dataList: getmatchStudy,
      });
      
    }
   
  }
);
const matchArtData = Mock.mock(
  "http://localhost:5174/home/match/art",
  "post",
  function (options) {
    const id = JSON.parse(options.body).id;
    console.log(
      "mock获取的参数" +
        id
    );
    let i=0,j=0
    for (i = 0,j=0; i < MatchArt.length; i++) {
      if (MatchArt[i].id == id) {
        console.log("找到了一个呢"+MatchArt[i].projectname)

        getmatchArt[j]=MatchArt[i];
        j++;
     }
  
    }

    if(i<MatchArt.length){
      return Mock.mock({
        status: 404,
        message:'你没有获得该竞赛奖呢',
        dataList: [
          {
          
          },
        ],
        });
    }else{
      console.log('获取竞赛成功')
      return Mock.mock({
        status: 200,
        dataList: getmatchArt,
      });
      
    }
   
  }
);

//证书
const certificateStudyData = Mock.mock(
  "http://localhost:5174/home/certificate/study",
  "post",
  function (options) {
    const id = JSON.parse(options.body).id;
    console.log(
      "mock获取的参数" +
        id
    );
    let i=0,j=0
    for (i = 0,j=0; i < CertificateStudy.length; i++) {
      if (CertificateStudy[i].id == id) {
        console.log("找到了一个呢"+CertificateStudy[i].projectname)

        getcertificateStudy[j]=CertificateStudy[i];
        j++;
     }
  
    }

    if(i<CertificateStudy.length){
      return Mock.mock({
        status: 404,
        message:'你没有获得该证书奖呢',
        dataList: [
          {
          
          },
        ],
        });
    }else{
      console.log('获取证书成功')
      return Mock.mock({
        status: 200,
        dataList: getcertificateStudy,
      });
      
    }
   
  }
);
const certificateArtData = Mock.mock(
  "http://localhost:5174/home/certificate/art",
  "post",
  function (options) {
    const id = JSON.parse(options.body).id;
    console.log(
      "mock获取的参数" +
        id
    );
    let i=0,j=0
    for (i = 0,j=0; i < CertificateArt.length; i++) {
      if (CertificateArt[i].id == id) {
        console.log("找到了一个呢"+CertificateArt[i].projectname)

        getcertificateArt[j]=CertificateArt[i];
        j++;
     }
  
    }

    if(i<CertificateArt.length){
      return Mock.mock({
        status: 404,
        message:'你没有获得该竞赛奖呢',
        dataList: [
          {
          
          },
        ],
        });
    }else{
      console.log('获取竞赛成功')
      return Mock.mock({
        status: 200,
        dataList: getcertificateArt,
      });
      
    }
   
  }
);
const certificateVolunteerData = Mock.mock(
  "http://localhost:5174/home/certificate/volunteer",
  "post",
  function (options) {
    const id = JSON.parse(options.body).id;
    console.log(
      "mock获取的参数" +
        id
    );
    let i=0,j=0
    for (i = 0,j=0; i < CertificateVolunteer.length; i++) {
      if (CertificateVolunteer[i].id == id) {
        console.log("找到了一个呢"+CertificateVolunteer[i].projectname)

        getcertificateVolunteer[j]=CertificateVolunteer[i];
        j++;
     }
  
    }

    if(i<CertificateVolunteer.length){
      return Mock.mock({
        status: 404,
        message:'你没有获得该竞赛奖呢',
        dataList: [
          {
          
          },
        ],
        });
    }else{
      console.log('获取竞赛成功')
      return Mock.mock({
        status: 200,
        dataList: getcertificateVolunteer,
      });
      
    }
   
  }
);

//奖学金

//项目
const projectData = Mock.mock(
  "http://localhost:5174/home/project",
  "post",
  function (options) {
    const id = JSON.parse(options.body).id;
    console.log(
      "mock获取的参数" +
        id
    );
    let i=0,j=0
    for (i = 0,j=0; i < Project.length; i++) {
      if (Project[i].id == id) {
        console.log("找到了一个呢"+Project[i].projectname)

        getProject[j]=Project[i];
        j++;
     }
  
    }

    if(i<Project.length){
      return Mock.mock({
        status: 404,
        message:'你没有获得该证书奖呢',
        dataList: [
          {
          
          },
        ],
        });
    }else{
      console.log('获取证书成功')
      return Mock.mock({
        status: 200,
        dataList: getProject,
      });
      
    }
   
  }
);
//实习
const practiceData = Mock.mock(
  "http://localhost:5174/home/practice",
  "post",
  function (options) {
    const id = JSON.parse(options.body).id;
    console.log(
      "mock获取的参数" +
        id
    );
    let i=0,j=0
    for (i = 0,j=0; i < Practice.length; i++) {
      if (Practice[i].id == id) {
        console.log("找到了一个呢"+Practice[i].projectname)

        getPractice[j]=Practice[i];
        j++;
     }
  
    }

    if(i<Practice.length){
      return Mock.mock({
        status: 404,
        message:'你没有获得该证书奖呢',
        dataList: [
          {
          
          },
        ],
        });
    }else{
      console.log('获取证书成功')
      return Mock.mock({
        status: 200,
        dataList: getPractice,
      });
      
    }
   
  }
);
//论文
const paperData = Mock.mock(
  "http://localhost:5174/home/paper",
  "post",
  function (options) {
    const id = JSON.parse(options.body).id;
    console.log(
      "mock获取的参数" +
        id
    );
    let i=0,j=0
    for (i = 0,j=0; i < Paper.length; i++) {
      if (Paper[i].id == id) {
        console.log("找到了一个呢"+Paper[i].projectname)

        getPaper[j]=Paper[i];
        j++;
     }
  
    }

    if(i<Paper.length){
      return Mock.mock({
        status: 404,
        message:'你没有获得该证书奖呢',
        dataList: [
          {
          
          },
        ],
        });
    }else{
      console.log('获取证书成功')
      return Mock.mock({
        status: 200,
        dataList: getPaper,
      });
      
    }
   
  }
);


export default
 { testData, 
  //登录
  loginData, 
  //个人信息
  personData ,
  personSubmitData,
  //竞赛
  matchStudyData,
  matchArtData,
  //证书
  certificateStudyData,
  certificateArtData,
  certificateVolunteerData,
  //奖学金

  //项目
  projectData,
  //实习
  practiceData  ,
//论文
paperData
};
